package com.example.javawebdemo.strategy;

import org.mindrot.jbcrypt.BCrypt;

/*
5.策略模式 (Strategy) - 密码加密算法可扩展
 */

public class BCryptHasher implements PasswordHasher {
    @Override
    public String hash(String password) {
        return BCrypt.hashpw(password, BCrypt.gensalt());
    }

    @Override
    public boolean check(String password, String hashedPassword) {
        return BCrypt.checkpw(password, hashedPassword);
    }
}
